package com.liehu.user.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.liehu.user.pojo.Employee;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface EmployeeMapper extends BaseMapper<Employee> {

    //根据工号查询
    @Select("select * from tb_employee where job_number = #{job_number}")
    public Employee findByJobNumber(String jobNumber);

    //根据电话号码查询
    @Select("select * from tb_employee where mobile = #{mobile}")
    public Employee findByMobile(String mobile);

    //修改密码--用于当前用户修改密码
    @Update("UPDATE tb_employee SET PASSWORD =  #{password} WHERE id = #{id}")
    public void updateByPassword(String id,String password);
    //根据角色id查询业务员Id
    @Select("SELECT DISTINCT e.id FROM tb_employee e,tb_role r WHERE e.role_id = r.id AND e.role_id = #{roleId} ")
    public List<Employee> findByRoleId(String roleId);

    //修改员工的状态为离职，且需要管理员权限操作
    @Update("UPDATE tb_employee SET STATUS = '0' WHERE id = #{employeeId}")
    void updateStatus(String employeeId);
}
